#ifndef __BINTREE_H
#define __BINTREE_H 

#include "BinNode.h"

template <typename T> 
class BinTree{
protected:
	int _size;
	BinNode<T> *_root;
//	virtual int updateHeight(BinNode<T> *x);
	void updateHeightAbove(BinNode<T> *x);

public:
	int remove(BinNode<T> *x);
	BinTree():_size(0),_root(NULL){}
	~BinTree(){
		if(0 < _size)
			remove(_root);
	}

	int size() const {return _size;}
	bool empty() const {return !_root;}
	BinNode<T> *root(){return _root;}
	BinNode<T> *insertAsRoot(const T &e);
	BinNode<T> *insertAsLC(BinNode<T> *x,const T &e);
	BinNode<T> *insertAsRC(BinNode<T> *x,const T &e);
};

#endif
